package net.httpconn;

import java.io.IOException;
import java.net.MalformedURLException;

/**
 * @author nico
 *
 */
public class HttpConnection implements java.io.Serializable {

    /**
     * @param method
     * @param url
     * @param requestContent
     * @param c_type
     * @param timeout
     * @return String response
     */
    public static String run(String method, String url, String requestContent, String c_type, int timeout) throws MalformedURLException, IOException {
        return execution(method, url, requestContent, c_type, timeout);
    }

    /**
     * @param method
     * @param url
     * @param requestContent
     * @param c_type
     * @return String response
     */
    public static String run(String method, String url, String requestContent, String c_type) throws MalformedURLException, IOException {
        return execution(method, url, requestContent, c_type, -1);
    }
    
    private static String execution(String method, String url, String requestContent, String c_type, int timeout) throws MalformedURLException, IOException {
        HttpCommand myCommand = HttpCommandFactory.getCommand(method, url, requestContent, c_type, timeout);
        return myCommand.execute();
    }
}
